/*
剑指 Offer 46. 把数字翻译成字符串
解题思路：滑动数组思想
 */
public class Offer46 {
  public static void main(String[] args) {
    System.out.println(new Offer46().translateNum(12258));
  }

  public int translateNum(int num) {
    String s = String.valueOf(num);
    int p = 0;
    int q = 0;
    int r = 1;
    for (int i = 0; i < s.length(); i++) {
      p = q;
      q = r;
      r = 0;
      r += q;
      if (i == 0){
        continue;
      }
      String pre = s.substring(i - 1, i + 1);
      if (pre.compareTo("25") <= 0 && pre.compareTo("10") >= 0) {
        r += p;
      }
    }
    return r;
  }
}
